package com.ailiwu.www.ailiwu.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Author:    XiYoung
 * Version    V1.0
 * Date:      2015/12/5 000515:48
 * Description:
 * Modification  History:
 * Date         	Author        		Version        	Description
 * -----------------------------------------------------------------------------------
 * 2015/12/5 0005       XiYoung              1.0                   1.0
 * Why & What is modified:
 */
public class SQLHelper extends SQLiteOpenHelper{
    public static final String DB_NAME = "database.db";// 数据库名称
    public static final int VERSION = 1;

    public static final String TABLE_CHANNEL = "channel";//数据表

    public static final String ID = "id";//
    public static final String NAME = "name";
    public static final String ORDERID = "orderId";
    public static final String SELECTED = "selected";

    private Context context;

    public SQLHelper(Context context) {
        super(context,DB_NAME,null,VERSION);
        this.context = context;
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        // 创建数据库后对数据库的操作
        String s = "create table if not exit"+TABLE_CHANNEL
                +"(_id INTEGER PRIMARY KEY AUTOINCREMENT,"
                +ID+"INTEGER"
                +NAME+"TEXT,"
                +ORDERID +"INTEGER,"
                +SELECTED+"SELECTED)";
        sqLiteDatabase.execSQL(s);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
        // TODO 更改数据库版本的操作
        onCreate(sqLiteDatabase);
    }

    public Context getContext(){
        return context;
    }
}
